<?php
/**
 * <i>regex_replace</i>定义
 * 
 * @version $Id: IMintRegexReplaceModifier.php 312 2008-04-23 16:29:38Z iwind $
 * @package util.mint.modifier
 * @since 0.0.2
 */
class IMintRegexReplaceModifier extends IAbstractMintModifier {
	/**
	 * 构造器
	 *
	 */	
	public function __construct() {
		
	}
	
	/**
	 * 执行
	 *
	 * @return scalar
	 */	
	public function execute(/** $server, $replace **/) {
		$string = $this->getVariable();
		$arguments = $this->getArguments();
		$search = isset($arguments[0])?$arguments[0]:"/.+/s";
		$replace = isset($arguments[1])?$arguments[1]:" ";
		
		$match = array();
		if (preg_match("/([a-zA-Z\\s]+)$/s", $search, $match) && strstr($match[1], "e")) {
          	$search = substr($search, 0, -strlen($match[1])) . preg_replace("/[e\\s]+/", "", $match[1]);
    	}
    	return preg_replace($search, $replace, $string);
	}
}

?>